<?php
class Form_Newsletter extends Zend_Form
{
    public function __construct($options=array())
    {
		parent::__construct($options);
		
		Zend_Loader::loadClass('Template', array('../application/admin/models/'));
		$this->setMethod('post');
		$mod_template = new Template();
		$tpl_arr = $mod_template->getTemplateInfo();
		
		$this->addPrefixPath('Lion_Form_Element', '../library/Form/Element/', 'element');
		
		
		
		$template = new Zend_Form_Element_Select('template_id');
		$template ->setLabel('Template');
		$template->setOptions(array('class'=>'input-2'));
		
		$template->addMultiOption('', 'Select Template'); 		  
        foreach ($tpl_arr as $tpl_entry)
		{
			$template->addMultiOption($tpl_entry['template_id'], $tpl_entry['template_title']);
		}
		
		//$template->SetValue('');
		
		$this->addElement($template);
		
		$newsletter_title = $this->addElement('text', 'newsletter_title', array(
            'label'      => 'Newsletter Title:',
            'filters'    => array('StringTrim'),
            'class'			 => 'input-2',
            'validators' => array(
            	array('validator' => 'StringLength', 'options' => array(0, 100))
            )
        ));
        
        //$newsletter_title->addDecorator('HtmlTag', array('tag'=>'div', 'class'=>'form-sect-2','placement'=>'append'));

        
        //$newsletter_title->addDecorator('HtmlTag', array('tag'=>'div', 'class'=>'form-sect-2', 'closeOnly'=>true, 'placement'=>'append'));
		
        $newsletter_content = $this ->addElement('formRTE', 'newsletter_content',
    				array('label' =>'Newsletter Content:',
    					'validators' =>array(
    					array('validator' =>'StringLength', 'options' =>array(0, 1000))
    				),
		));
		
		//$newsletter_content->addDecorator('HtmlTag', array('tag'=>'div', 'class'=>'form-sect-2','placement'=>'append'));
		
		if(!empty($options))
		{
    		if($options['action'] == "edit")
    		{ 
        	   	$this->addElement('hidden', 'newsletter_id', array(	            
        	            'filters'  => array('int'),
        	            'class'	   => 'hidden',
        	            'value'    => $options['newsletter_id'],	            
        	    ));
    		}
		}
		//$this->addElement('submit', $btn_label);
    }
}
